import bean.*;
import com.sun.org.apache.xalan.internal.utils.FeatureManager;
import org.junit.Test;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MyApplication {

    private HashMap map = new HashMap();

    @Test
    public void test() {
        final Person lili = new Woman("a women can offSpring");
        System.out.println("MyApplication-lili:" + lili);
//        lili = new Woman("");

        final String name = "longlong";
        System.out.println("MyApplication-lili:" + name);
//        name = "lili";
    }

    @Test
    public void equalTest() {
        Woman woman1 = new Woman();
        Woman woman2 = new Woman();
        Woman woman = woman1;
        System.out.println("woman1==woman:" + (woman == woman1));
        System.out.println("woman2==woman1:" + (woman2 == woman1));
        String str1 = "abc";
        String str2 = "abc";
        String ss = str1;
        System.out.println("str1==ss:" + (str1 == ss));
        System.out.println("str1==str2:" + (str1 == str2));
        System.out.println("str1.equal.ss:" + (str1.equals(ss)));
        System.out.println("str1.equal.str2:" + (str1.equals(str2)));
        int a = 12;
        int b = a;
        int c = 12;
        System.out.println("a==b:" + (a == b));
        System.out.println("a==c:" + (a == c));

    }

    @Test
    public void testErasure(){
        // 泛型类的创建
        TestErase<String> testErase = new TestErase<>();

//        List<String> list = new ArrayList<>();
//        List<Integer> list2 = new ArrayList<>();
//        testErase.testList(list);
//        testErase.testList(list2);

        Class aClass = testErase.getClass();
        System.out.println("aClass:"+aClass);
        try {
            Method method = aClass.getDeclaredMethod("add", String.class);
            Field[] declaredFields = aClass.getDeclaredFields();
            for (Field field : declaredFields) {
                System.out.println("field-name:"+field.getName()+"--field-Type:"+field.getType());
            }
            try {
                method.invoke(testErase,"123456789");
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }


    }

    @Test
    public void testString(){
        String s1 = "digua";
        String s2 = "digua";
        System.out.println("s1 == s2:"+(s1 == s2));
        String s3 = new String("digua");
        String s4 = new String("digua");
        System.out.println("s1 == s3:"+(s1 == s3));
        System.out.println("s3 == s4:"+(s3 == s4));

        String s5 = new String("digua");
        String s6 = s3.intern();
        System.out.println("s1 == s6:"+(s1 == s6));

    }


}
